Package org.apache.flink.autoscaler
Class ScalingTracking
- java.lang.Object
-
- org.apache.flink.autoscaler.ScalingTracking
-
@Experimental public class ScalingTracking extends java.lang.Object
Stores rescaling related information for the job.
-
-
Constructor Summary
Constructors Constructor Description ScalingTracking()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addScalingRecord(java.time.Instant startTimestamp, ScalingRecord scalingRecord)
java.util.Optional<java.util.Map.Entry<java.time.Instant,ScalingRecord>>
getLatestScalingRecordEntry()
java.time.Duration
getMaxRestartTimeOrDefault(org.apache.flink.configuration.Configuration conf)
Retrieves the maximum restart time based on the provided configuration and scaling records.boolean
recordRestartDurationIfTrackedAndParallelismMatches(java.time.Instant jobRunningTs, JobTopology jobTopology, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
Sets restart duration for the latest scaling record if its parallelism matches the current job parallelism.void
removeOldRecords(java.time.Instant now, java.time.Duration keptTimeSpan, int keptNumRecords)
Removes all but one records from the internal map that are older than the specified time span and trims the number of records to the specified maximum count.
-
-
-
Method Detail
-
addScalingRecord
public void addScalingRecord(java.time.Instant startTimestamp, ScalingRecord scalingRecord)
-
getLatestScalingRecordEntry
public java.util.Optional<java.util.Map.Entry<java.time.Instant,ScalingRecord>> getLatestScalingRecordEntry()
-
recordRestartDurationIfTrackedAndParallelismMatches
public boolean recordRestartDurationIfTrackedAndParallelismMatches(java.time.Instant jobRunningTs, JobTopology jobTopology, java.util.Map<org.apache.flink.runtime.jobgraph.JobVertexID,java.util.SortedMap<java.time.Instant,ScalingSummary>> scalingHistory)
Sets restart duration for the latest scaling record if its parallelism matches the current job parallelism.- Parameters:
jobRunningTs
- The instant when the JobStatus is switched to RUNNING, it will be used as the end time when calculating the restart duration.jobTopology
- The current job topology containing details of the job's parallelism.scalingHistory
- The scaling history.- Returns:
- true if the restart duration is successfully recorded, false if the restart duration is already set, the latest scaling record cannot be found, or the target parallelism does not match the actual parallelism.
-
getMaxRestartTimeOrDefault
public java.time.Duration getMaxRestartTimeOrDefault(org.apache.flink.configuration.Configuration conf)
Retrieves the maximum restart time based on the provided configuration and scaling records. Defaults to the RESTART_TIME from configuration if the PREFER_TRACKED_RESTART_TIME option is set to false, or if there are no tracking records available. Otherwise, the maximum observed restart time is capped by the MAX_RESTART_TIME.
-
removeOldRecords
public void removeOldRecords(java.time.Instant now, java.time.Duration keptTimeSpan, int keptNumRecords)
Removes all but one records from the internal map that are older than the specified time span and trims the number of records to the specified maximum count. Always keeps at least one latest entry.- Parameters:
keptTimeSpan
- Duration for how long recent records are to be kept.keptNumRecords
- The maximum number of recent records to keep.
-
-