Skip to content

Commit

Permalink
FM-751 Add config property for SCALED_BY_TASK_DURATION strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
jaro0149 committed Nov 18, 2024
1 parent 9f92dd7 commit 49e2a98
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
Expand Down Expand Up @@ -108,6 +109,24 @@ public class ConductorProperties {
private Map<TaskType, OffsetEvaluationStrategy> systemTaskOffsetEvaluation =
Map.of(TaskType.JOIN, OffsetEvaluationStrategy.BACKOFF_TO_DEFAULT_OFFSET);

/**
* The duration of the task execution mapped to the calculated offset of the postponed task
* [seconds].<br>
* This setting is used only by the {@link OffsetEvaluationStrategy#SCALED_BY_TASK_DURATION}
* offset evaluation strategy.<br>
* Example: If map contains two entries (10, 30) and (20, 60), then the evaluation offsets for
* the postponed tasks in the queue will be calculated according to the following intervals:
*
* <ul>
* <li><0,10) seconds: offset = 0 seconds
* <li><10-20) seconds: offset = 30 seconds
* <li><20-N) seconds: offset = 60 seconds
* </ul>
*
* By default, the offset is always set to 0 seconds.
*/
private Map<Long, Long> taskDurationToOffsetSteps = Collections.emptyMap();

/**
* The interval (in milliseconds) at which system task queues will be polled by the system task
* workers.
Expand Down Expand Up @@ -373,6 +392,14 @@ public Map<TaskType, OffsetEvaluationStrategy> getSystemTaskOffsetEvaluation() {
return systemTaskOffsetEvaluation;
}

public Map<Long, Long> getTaskDurationToOffsetSteps() {
return taskDurationToOffsetSteps;
}

public void setTaskDurationToOffsetSteps(Map<Long, Long> taskDurationToOffsetSteps) {
this.taskDurationToOffsetSteps = taskDurationToOffsetSteps;
}

public void setSystemTaskWorkerCallbackDuration(Duration systemTaskWorkerCallbackDuration) {
this.systemTaskWorkerCallbackDuration = systemTaskWorkerCallbackDuration;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,13 @@ public enum OffsetEvaluationStrategy {
* poll count. In this strategy offset increases exponentially until it reaches the (default
* offset * queue size) value.
*/
SCALED_BY_QUEUE_SIZE;
SCALED_BY_QUEUE_SIZE,
/**
* Computes the evaluation offset for a postponed task based on the task's duration. In this
* strategy offset increases by steps that are proportional to the task's duration and defined
* by the user settings.
*
* @see ConductorProperties#getTaskDurationToOffsetSteps() setting used to define the steps
*/
SCALED_BY_TASK_DURATION
}

0 comments on commit 49e2a98

Please sign in to comment.